﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace Appsters
{
    public partial class notes : Form
    {
        public notes()
        {
            InitializeComponent();
        }

        private void Form4_Load(object sender, EventArgs e)
        {
            GraphicsPath g = new GraphicsPath();
            g.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
            Region r = new System.Drawing.Region(g);
        }

        private void exit_Click(object sender, EventArgs e)
        {
            //shouldn't this window go back to Profile view? O.O
            Application.Exit();
        }

        private void save_Click(object sender, EventArgs e)
        {
            //get date
            string d = date.Value.ToString("yyyy-MM-dd");

            //get Title
            string t = title.Text;

            //combined filename format
            //String.Format("{0:yyyy-MM-dd}__{1}", d, t);
            string f = d + "_" + t; 
            
            //save in folder 
            string docPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string notesFolder = System.IO.Path.Combine(docPath, "Jotter\\Saved Files\\Notes");
            System.IO.Directory.CreateDirectory(notesFolder);

            string path = System.IO.Path.Combine(notesFolder, f + ".txt");            
                                    
            System.IO.File.WriteAllText(path, writeBox.Text);

            MessageBox.Show("You just saved a text file in your My Documents folder, inside Jotter folder." +
                            "After this section, the form's supposed to lead to the Monthly View already. xD");
            
            //go to planner 
            planner p = new planner();
            p.Show();
            this.Hide();
        }

        private void min_Click(object sender, EventArgs e)
        {
            WindowState = FormWindowState.Minimized;
        }

        private void del_Click(object sender, EventArgs e)
        {
            //delete notes
            string docPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string comPath = System.IO.Path.Combine(docPath, "Jotter\\Saved Files\\Notes");
            System.Diagnostics.Process.Start(@comPath); // open the folder where notes are located
        }

        private void recent_Click(object sender, EventArgs e)
        {
            string docPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string comPath = System.IO.Path.Combine(docPath, "Jotter\\Saved Files\\Notes");
            System.Diagnostics.Process.Start(@comPath); // open the folder where notes are located
        }

        private void backButton_Click(object sender, EventArgs e)
        {
            profView pv = new profView();
            pv.Show();
            this.Hide();
        }
    }
}
